package UDPServer;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictServer extends UdpEchoServer{
    private Map<String,String> map = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        map.put("hello","你好");
        map.put("good","棒");
        map.put("continue","继续");
        map.put("apartment","公寓");
        map.put("cat","猫");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"查询不到此单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer udpDictServer = new UdpDictServer(9191);
        udpDictServer.start();
    }
}
